<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable=['goods_id','attributeArr','extraPrice','inventory'];
    protected $casts=[
        'attributeArr'=>'array',
    ];
    //根据属性id找到属性名
    public function getAttrName($attributeArr){
    $name=[];
    foreach ($attributeArr as $value){
        $name[]=Attribute::where('id',$value)->value('name');
    }
    return json_encode($name,JSON_UNESCAPED_UNICODE);
    }
}
